<template>
  <div class="help">
    <el-form ref="formData" :model="formData" :rules="rules" size="medium" label-width="100px" class="help-form">
      <el-form-item label="老师名字" prop="teacherName">
        <el-input v-model="formData.teacherName" placeholder="请输入老师名字" :maxlength="11" show-word-limit
                  :disabled='true' clearable prefix-icon='el-icon-mobile' :style="{width: '100%'}"></el-input>
      </el-form-item>
      <el-form-item label="学生名字" prop="studentName">
        <el-input v-model="formData.studentName"  :disabled='true'
                  placeholder="请输入学生名字" clearable :style="{width: '100%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="处理时间" prop="assistTime">
        <el-time-picker v-model="formData.assistTime" format="yyyy-MM-dd" value-format="yyyy-MM-dd"  :disabled='true'
                        :picker-options='{"selectableRange":"00:00:00-23:59:59"}' :style="{width: '100%'}"
                        placeholder="请选择处理时间" clearable></el-time-picker>
      </el-form-item>
      <el-form-item label="问题类型" prop="field103">
        <el-input v-model="formData.problemType"  :disabled='true' placeholder="请输入问题类型" clearable :style="{width: '100%'}">
        </el-input>
      </el-form-item>
      <el-form-item label="评价分数" prop="score">
        <el-rate v-model="formData.score"></el-rate>
      </el-form-item>
      <el-form-item label="评价描述" prop="description">
        <el-input v-model="formData.description" type="textarea" placeholder="请输入评价描述"
                  :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { getAssist , addComment } from "@/api/evaluate/evaluate";

export default {
  components: {},
  props: [],
  data() {
    return {
      form:{},
      formData: {
        teacherName: '',
        studentName: undefined,
        assistTime: null,
        field103: undefined,
        score: 5,
        description: undefined,
      },
      rules: {
        teacherName: [{
          required: true,
          message: '请输入老师名字',
          trigger: 'blur'
        }],
        studentName: [{
          required: true,
          message: '请输入学生名字',
          trigger: 'blur'
        }],
        assistTime: [{
          required: true,
          message: '请选择处理时间',
          trigger: 'change'
        }],
        problemType: [{
          required: true,
          message: '请输入问题类型',
          trigger: 'blur'
        }],
        score: [],
        description: [{
          required: true,
          message: '请输入评价描述',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {
    this.getAssistDetail();
  },
  mounted() {},
  methods: {
    getAssistDetail() {
      let url = window.location.href.split("=")
      var str = unescape(url[1])
      this.form.code = str
      console.log(this.form)
      getAssist(this.form).then(res => {
        this.formData.teacherName = res.data.teacher
        this.formData.studentName = res.data.studentName
        this.formData.assistTime = res.data.bookedTime
        this.formData.problemType = res.data.problemType
        this.formData.assisId = res.data.id
      })
    },
    submitForm() {
      this.$refs['formData'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
        console.log(this.formData)
        addComment(this.formData).then(res => {

          this.$modal.msgSuccess("评价成功");
        })
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
  }
}

</script>
<style rel="stylesheet/scss" lang="scss">
.help {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  background-image: url("../../assets/images/login-background.jpg");
  background-size: cover;
}
.title {
  margin: 0px auto 30px auto;
  text-align: center;
  color: #707070;
}
.help-tip {
  font-size: 13px;
  text-align: center;
  color: #bfbfbf;
}
.help-form {
  border-radius: 6px;
  background: #ffffff;
  width: 521px;
  padding: 25px 25px 5px 25px;
  .el-input {
    height: 38px;
    input {
      height: 38px;
    }
  }
  .input-icon {
    height: 39px;
    width: 14px;
    margin-left: 2px;
  }
}
</style>
